<?php
require_once('Db.php');
Db::init();

$row = Db::fetchRow('SELECT COUNT(DISTINCT school_id) AS opened FROM logs;');
$opened = $row['opened'];
$row = Db::fetchRow('SELECT COUNT(DISTINCT school_id) AS posted FROM logs WHERE action="form post";');
$posted = $row['posted'];
$received = 5282;
$schools = 6717;
$odkazy = Db::fetchAll('SELECT sa.answer_specified,s.miesto FROM schools_answers AS sa LEFT JOIN schools AS s ON sa.school_id=s.school_id WHERE sa.answer_id=54');
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';

echo '<div style="float:top;display:block;padding:0px;border:1px solid black;width:200px;height:30px;text-align:right;">Všetky školy</div>';
echo '<div style="float:top;display:block;padding:0px;width:200px;height:30px;background-color:yellow;text-align:right;">Koľkým došiel mail</div>';
echo '<div style="float:top;display:block;padding:0px;width:200px;height:30px;background-color:#ff5555;text-align:right;">Koľkí ho otvorili</div>';
echo '<div style="float:top;display:block;padding:0px;width:200px;height:30px;background-color:#33ff33;text-align:right;">Koľkí ho vyplnili</div><br/>';

echo '<div style="float:left;display:inline-block;padding:0px;border:1px solid black;width:'.($schools/5).'px;height:30px;text-align:right;">';
echo '<div style="float:left;display:inline-block;padding:0px;height:26px;width:'.($received/5).'px;background-color:yellow">';
echo '<div style="float:left;display:inline-block;padding:0px;height:22px;width:'.($opened/5).'px;background-color:#ff5555">';
echo '<div style="float:left;display:inline-block;padding:0px;height:18px;width:'.($posted/5).'px;background-color:#33ff33">';
echo $posted;
echo '</div>';
echo $opened;
echo '</div>';
echo $received;
echo '</div>';
echo $schools;
echo '</div><br/><br/>';
foreach($odkazy as $odkaz)
{
  echo $odkaz['miesto'] . ":<br/>\n" . $odkaz['answer_specified'] . "<br/>\n<br/>\n";
}
Db::close();
?>

